export default ({ request, serviceForMock, mock, faker }) => {

  // Mock数据配置
  mock.onGet('/finance/recharge/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 50,
        pageSize: 10,
        totalPage: 5,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          tenantName: faker.name.findName(),
          roomNumber: `10${index + 1}`,
          rechargeAmount: faker.random.number({ min: 100, max: 500 }),
         // rechargeTime: faker.date.recent().toISOString().split('T')[0],
          paymentMethod: ['微信', '支付宝', '现金', '银行卡'][index % 4],
          status: ['已完成', '处理中', '已取消'][index % 3]
        }))
      }
    }
  })

  mock.onGet('/finance/reconciliation/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 30,
        pageSize: 10,
        totalPage: 3,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          date: faker.date.recent().toISOString().split('T')[0],
          totalIncome: faker.random.number({ min: 5000, max: 15000 }),
          totalExpense: faker.random.number({ min: 1000, max: 5000 }),
          balance: faker.random.number({ min: 3000, max: 10000 }),
          status: ['已对账', '待对账'][index % 2]
        }))
      }
    }
  })

  mock.onGet('/finance/records/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 100,
        pageSize: 10,
        totalPage: 10,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          tenantName: faker.name.findName(),
          roomNumber: `10${index + 1}`,
          amount: faker.random.number({ min: 50, max: 300 }),
          //rechargeTime: faker.date.recent().toISOString().split('T')[0] + ' ' + faker.time.recent(),
          paymentMethod: ['微信', '支付宝', '现金', '银行卡'][index % 4],
          operator: '管理员'
        }))
      }
    }
  })

  mock.onGet('/finance/settlement/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 20,
        pageSize: 10,
        totalPage: 2,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          tenantName: faker.name.findName(),
          roomNumber: `10${index + 1}`,
          remainingBalance: faker.random.number({ min: 10, max: 200 }),
          deposit: faker.random.number({ min: 200, max: 500 }),
          settlementAmount: faker.random.number({ min: 150, max: 600 }),
          settlementTime: faker.date.recent().toISOString().split('T')[0],
          status: ['已结算', '待结算'][index % 2]
        }))
      }
    }
  })

  return {
    // 充值缴费
    finance_recharge_list(params = {}) {
      return request({
        url: '/finance/recharge/list',
        params
      })
    },

    finance_recharge_save(data = {}) {
      return request({
        url: '/finance/recharge/save',
        method: 'post',
        data
      })
    },

    // 财务对账
    finance_reconciliation_list(params = {}) {
      return request({
        url: '/finance/reconciliation/list',
        params
      })
    },

    finance_reconciliation_process(data = {}) {
      return request({
        url: '/finance/reconciliation/process',
        method: 'post',
        data
      })
    },

    // 充值记录
    finance_records_list(params = {}) {
      return request({
        url: '/finance/records/list',
        params
      })
    },

    // 销户结算
    finance_settlement_list(params = {}) {
      return request({
        url: '/finance/settlement/list',
        params
      })
    },

    finance_settlement_process(data = {}) {
      return request({
        url: '/finance/settlement/process',
        method: 'post',
        data
      })
    }
  }
}

